package extend_widget

import (
	"clientDemo/ui/fyne_ui/widget/interface"
	"clientDemo/ui/fyne_ui/widget/utils"
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/driver/desktop"
)

type EmptyContainer struct {
	MaxWidth  float32
	MaxHeight float32

	TouchBeganCallback widgetcommon.TouchCallback
	TouchEndedCallback widgetcommon.TouchCallback
	TouchMovedCallback widgetcommon.TouchCallback
}

func (e *EmptyContainer) SetMinSize(size fyne.Size) {
	e.MaxWidth = size.Width
	e.MaxHeight = size.Height
}

func (e *EmptyContainer) TransMouseMoved(ev *desktop.MouseEvent) {
	//log.Info("Mouse moved to: %v %v\n", ev.AbsolutePosition, ev.Position)
}

func (e *EmptyContainer) TransMouseDown(ev *desktop.MouseEvent) {
	//log.Info("Mouse button pressed")
}

func (e *EmptyContainer) TransMouseUp(ev *desktop.MouseEvent) {
	//fmt.Println("Mouse button released")
}

func (e *EmptyContainer) SetTouchBeganCallback(cb widgetcommon.TouchCallback) {
	e.TouchBeganCallback = cb
}
func (e *EmptyContainer) SetTouchMovedCallback(cb widgetcommon.TouchCallback) {
	e.TouchMovedCallback = cb
}
func (e *EmptyContainer) SetTouchEndedCallback(cb widgetcommon.TouchCallback) {
	e.TouchEndedCallback = cb
}

type EmptyMasterContainer struct {
	*WidgetContainer
	*EmptyContainer
}

func (e *EmptyMasterContainer) MinSize(objects []fyne.CanvasObject) fyne.Size {
	w, h := float32(0), float32(0)
	for _, o := range objects {
		childSize := o.MinSize()
		pos := e.positions[o]
		w = utils.Max(w, pos.X+childSize.Width)
		h = utils.Max(h, pos.Y+childSize.Height)
	}
	return fyne.NewSize(w, h)
}
